1 00:00:00,240 --> 00:00:05,640 In this video, I'm going to reinforce the scripting skills from the last couple of videos by turning 2 00:00:05,640 --> 00:00:09,030 my part right here into a patio for my shack. 3 00:00:09,030 --> 00:00:10,890 So I'm using my first game. 4 00:00:10,890 --> 00:00:12,240 You could use a fresh world. 5 00:00:12,240 --> 00:00:13,680 Just go ahead and add a part. 6 00:00:13,680 --> 00:00:18,510 But if you are using my first game, go to my part. 7 00:00:18,600 --> 00:00:22,980 Did that move it script and disable it because we don't want our patio moving around. 8 00:00:23,580 --> 00:00:25,050 All right, go to my part. 9 00:00:25,080 --> 00:00:29,820 We're going to rename that to Patio and then hit this. 10 00:00:29,820 --> 00:00:32,340 Plus, sign out a script. 11 00:00:32,850 --> 00:00:36,150 And the script is going to be called Create Patio. 12 00:00:38,700 --> 00:00:39,480 Cool. 13 00:00:39,840 --> 00:00:44,250 I can go ahead and get rid of this print statement. 14 00:00:44,250 --> 00:00:46,450 And then I remember how I made a comment. 15 00:00:46,470 --> 00:00:48,030 Let's go ahead and review that. 16 00:00:48,180 --> 00:00:54,120 Dash, dash, declare variables. 17 00:00:54,990 --> 00:00:55,640 That's good. 18 00:00:55,650 --> 00:00:57,870 A good habit to get into is the comment. 19 00:00:57,900 --> 00:01:00,210 Let's go ahead and declare our variable. 20 00:01:00,210 --> 00:01:04,770 So we have local our scope modifier saying we're only going to use this variable in this script. 21 00:01:05,280 --> 00:01:09,300 I'll say patio, you can name this whatever you want as long as it makes sense. 22 00:01:09,420 --> 00:01:17,310 And then I'll say script dot parent this gets a reference using this scripts parent then sticks it in 23 00:01:17,310 --> 00:01:21,030 here so that we can modify the properties in the patio. 24 00:01:21,630 --> 00:01:24,240 All right, let's go ahead and do a print statement. 25 00:01:25,470 --> 00:01:29,450 Print statements are great for debugging so you can see where you are in the code. 26 00:01:29,460 --> 00:01:30,730 We're only going to use two. 27 00:01:30,750 --> 00:01:38,190 I'll say start creating patio, right? 28 00:01:38,190 --> 00:01:46,410 And then at the end we'll say print, stop creating patio or something similar. 29 00:01:48,510 --> 00:01:52,480 That way, if this never executes, we know there is something in the middle. 30 00:01:52,500 --> 00:01:54,270 Might want to add another print statement. 31 00:01:55,260 --> 00:01:57,000 All right, let's see. 32 00:01:57,060 --> 00:02:03,480 We want to start out with our patio invisible and have it magically appear. 33 00:02:03,480 --> 00:02:05,100 So let me go ahead. 34 00:02:05,490 --> 00:02:09,510 If you'll notice that the spaces here, the interpreter just skips right over them. 35 00:02:09,510 --> 00:02:11,790 Therefore, you you can put spaces if you want. 36 00:02:11,790 --> 00:02:13,800 You can get rid of the spaces if you want. 37 00:02:13,980 --> 00:02:15,470 I like it for readability. 38 00:02:15,480 --> 00:02:20,250 I'm going to do this dash dash for a comment that's for me, not for the interpreter. 39 00:02:20,280 --> 00:02:25,200 And I'm going to say, start with the patio. 40 00:02:25,200 --> 00:02:26,910 Invisible. 41 00:02:27,720 --> 00:02:27,960 All right. 42 00:02:27,960 --> 00:02:28,940 How do we do that? 43 00:02:28,950 --> 00:02:31,530 We have our patio variable. 44 00:02:31,530 --> 00:02:33,450 We have transparency. 45 00:02:33,930 --> 00:02:40,950 Remember, zero is fully opaque, one is fully transparent, which means it is invisible. 46 00:02:40,950 --> 00:02:42,930 So we want it to be one. 47 00:02:44,190 --> 00:02:44,550 All right. 48 00:02:44,550 --> 00:02:51,600 Let's wait 6 seconds that so that we can enter the world and then we'll say patio. 49 00:02:51,990 --> 00:02:56,690 Transparency equals zero and we'll see it magically appear. 50 00:02:56,700 --> 00:03:02,400 So we should see these in the output window and we should see our patio up here. 51 00:03:02,490 --> 00:03:07,860 Let's go to my game view output so we can see the output window. 52 00:03:07,860 --> 00:03:09,720 You can see I played that once already. 53 00:03:09,750 --> 00:03:10,950 Let's go ahead and get rid of it. 54 00:03:11,520 --> 00:03:12,630 Go to home. 55 00:03:13,500 --> 00:03:14,430 Start. 56 00:03:16,000 --> 00:03:17,650 Creating patio. 57 00:03:21,020 --> 00:03:22,700 But there's our part. 58 00:03:22,940 --> 00:03:24,230 That's pretty cool. 59 00:03:24,260 --> 00:03:25,480 Let's go ahead and add to it. 60 00:03:25,490 --> 00:03:28,040 It's not really a great patio right now, is it? 61 00:03:28,280 --> 00:03:35,960 Stop that and I'll put another I'll put another comment. 62 00:03:35,960 --> 00:03:37,880 We can get rid of this so we have more space. 63 00:03:38,120 --> 00:03:43,460 I'll put another comment in here and I'll say, change the size. 64 00:03:48,060 --> 00:03:50,450 Of the patio. 65 00:03:51,410 --> 00:03:51,740 Cool. 66 00:03:51,770 --> 00:03:52,820 How do we do that? 67 00:03:53,510 --> 00:04:00,380 Well, let's wait a second after we do our transparency, just so we can see different changes. 68 00:04:00,650 --> 00:04:01,250 Right. 69 00:04:01,730 --> 00:04:04,640 We'll come down here, and that will change our size. 70 00:04:04,640 --> 00:04:07,460 So we need the patio variable. 71 00:04:07,910 --> 00:04:10,640 We have size right here. 72 00:04:10,670 --> 00:04:11,500 Look at that. 73 00:04:11,510 --> 00:04:13,050 That's a vector three. 74 00:04:13,070 --> 00:04:16,760 I don't know if you remember how to do vector three, but we're going to review it. 75 00:04:17,810 --> 00:04:19,010 We'll say vector three. 76 00:04:19,100 --> 00:04:21,140 Vector three holds three numbers. 77 00:04:21,350 --> 00:04:30,410 No, because we've got to create a new one and then we'll make the patio 15 studs on the X and we'll 78 00:04:30,410 --> 00:04:32,000 make it thin on the height. 79 00:04:32,040 --> 00:04:33,620 Point two on the height. 80 00:04:33,770 --> 00:04:35,960 15 studs on the Y. 81 00:04:36,710 --> 00:04:37,370 Cool. 82 00:04:37,400 --> 00:04:43,620 Let's go over to my first game, and then I notice right here the spawn location is here. 83 00:04:43,640 --> 00:04:47,400 I don't want that interfering with my patio, so I hit this move. 84 00:04:47,420 --> 00:04:49,280 I'm just going to move that over here. 85 00:04:49,700 --> 00:04:50,810 Don't go too far, though. 86 00:04:50,840 --> 00:04:52,220 That's how you get into the world. 87 00:04:52,520 --> 00:04:52,850 All right. 88 00:04:52,850 --> 00:04:54,040 Let's play this. 89 00:04:54,050 --> 00:04:55,160 We can hit our view. 90 00:04:55,190 --> 00:04:57,800 Look at the output window, see if we got any mistakes. 91 00:04:58,550 --> 00:04:59,690 Make it a little bigger. 92 00:04:59,930 --> 00:05:01,010 Go to home. 93 00:05:01,160 --> 00:05:02,150 Hit the play. 94 00:05:04,370 --> 00:05:06,420 Start creating patio. 95 00:05:06,440 --> 00:05:07,310 Where is it at? 96 00:05:09,370 --> 00:05:10,030 Bam. 97 00:05:10,540 --> 00:05:12,640 Yeah, that's pretty cool. 98 00:05:15,200 --> 00:05:16,550 But we need a closer. 99 00:05:16,550 --> 00:05:17,420 How do we get it? 100 00:05:17,420 --> 00:05:18,140 Closer. 101 00:05:18,350 --> 00:05:19,790 Let's stop the game. 102 00:05:21,020 --> 00:05:27,080 I want to take a look at the part right click on the part which is Patio now and then I'm going to look 103 00:05:27,080 --> 00:05:28,160 at the position. 104 00:05:29,510 --> 00:05:31,910 So this position right here and open it up. 105 00:05:31,910 --> 00:05:33,780 We've got X, Y and Z. 106 00:05:33,800 --> 00:05:37,470 I want the patio to be right in front of my shack. 107 00:05:37,490 --> 00:05:40,590 So X is about 26. 108 00:05:40,610 --> 00:05:44,380 Well, that's not quite right in front and it's not quite exact. 109 00:05:44,390 --> 00:05:46,790 Z is going to be about zero. 110 00:05:46,820 --> 00:05:49,140 If we want to know what this is. 111 00:05:49,160 --> 00:05:51,110 Notice how the model selects. 112 00:05:51,110 --> 00:05:55,010 Let's just select the floor by hitting alt and then clicking. 113 00:05:55,730 --> 00:05:57,290 Look at that that position. 114 00:05:57,290 --> 00:06:00,200 Zero on the x, zero on the z. 115 00:06:00,230 --> 00:06:02,750 This Y is 10.25. 116 00:06:02,750 --> 00:06:09,320 So that's the height of the terrain, which is ten studs, 0.25 is half of the size of the floor. 117 00:06:09,350 --> 00:06:12,380 The floor is 0.5, 0.5 sides high. 118 00:06:12,470 --> 00:06:15,620 So we want this. 119 00:06:15,620 --> 00:06:18,800 The ten is good, the ten something is good. 120 00:06:18,950 --> 00:06:21,470 The X is going to be positive. 121 00:06:21,470 --> 00:06:24,230 Your shack might be might be rotated. 122 00:06:24,230 --> 00:06:24,530 Right. 123 00:06:24,530 --> 00:06:26,900 So you might have to change the X or the Z. 124 00:06:26,930 --> 00:06:28,760 I don't have to change my Z. 125 00:06:28,760 --> 00:06:30,170 Zero will be good. 126 00:06:30,170 --> 00:06:34,580 And I want to make this one like 15 just to get a reference. 127 00:06:34,580 --> 00:06:35,030 All right. 128 00:06:35,030 --> 00:06:40,310 Let's go back to create Patio and now we are going to change the position. 129 00:06:40,460 --> 00:06:40,970 Dash. 130 00:06:40,970 --> 00:06:46,910 Dash changed the position of the patio. 131 00:06:47,540 --> 00:06:52,400 And then once again, let's let's wait a second so we can see it happen. 132 00:06:52,400 --> 00:06:57,320 So right after the size, let's go ahead and put a one second wait there. 133 00:06:58,100 --> 00:06:59,570 I'm going to go down here. 134 00:07:00,140 --> 00:07:03,080 Patio position. 135 00:07:03,740 --> 00:07:05,690 That's a vector three two because it's three numbers. 136 00:07:05,690 --> 00:07:14,690 We'll say vector three new and my four was zero, 10.5 and zero. 137 00:07:15,590 --> 00:07:22,550 And then I notice that I need to move this on the x, the positive x right depending on where your shack 138 00:07:22,550 --> 00:07:24,470 is located or oriented. 139 00:07:24,860 --> 00:07:24,930 Right? 140 00:07:25,040 --> 00:07:32,510 So we'll say 15 on the X, I'll keep this at 10.5. 141 00:07:32,900 --> 00:07:33,470 Right. 142 00:07:33,680 --> 00:07:36,740 And then 15 on No. 143 00:07:36,890 --> 00:07:40,640 Zero on the Z that I'll put it directly in front. 144 00:07:40,640 --> 00:07:46,880 So this number and this number you may have to mess around with based on the orientation of your shack. 145 00:07:49,240 --> 00:07:51,730 I may be both of them if your shock isn't centered. 146 00:07:52,480 --> 00:07:52,960 All right. 147 00:07:52,960 --> 00:07:53,580 There we go. 148 00:07:53,590 --> 00:07:54,610 We're going to watch it. 149 00:07:57,970 --> 00:07:58,930 Cool. 150 00:07:59,200 --> 00:08:00,490 Take a look at this, though. 151 00:08:02,630 --> 00:08:03,320 Do you see that? 152 00:08:03,320 --> 00:08:05,030 There's a little gap here. 153 00:08:05,450 --> 00:08:10,760 That's because we made this thinner, but we kept it at the 0.5, 10.5 height. 154 00:08:11,000 --> 00:08:12,090 You know what we could do? 155 00:08:12,110 --> 00:08:13,190 We can anchor it. 156 00:08:13,190 --> 00:08:17,580 Remember, we anchored it in another video and then have it plop down in place. 157 00:08:17,600 --> 00:08:19,100 That would be kind of cool. 158 00:08:19,220 --> 00:08:20,870 Let's go ahead and stop this. 159 00:08:21,680 --> 00:08:24,670 And then this right here, we'll select the patio. 160 00:08:24,680 --> 00:08:28,370 We'll go to Anchored and anchor it. 161 00:08:28,400 --> 00:08:29,420 Now let's see it. 162 00:08:29,420 --> 00:08:30,860 Plop down in place. 163 00:08:36,020 --> 00:08:37,370 It's visible. 164 00:08:37,670 --> 00:08:38,730 It got big. 165 00:08:38,750 --> 00:08:39,650 It moved. 166 00:08:39,650 --> 00:08:41,570 And then it plopped down in place. 167 00:08:41,600 --> 00:08:43,090 You can kind of see it. 168 00:08:43,100 --> 00:08:43,910 It's kind of hard. 169 00:08:43,910 --> 00:08:48,620 I can get rid of this, but you can see it's right on the ground, but it is not anchored. 170 00:08:48,620 --> 00:08:54,740 So it could be moved or what you can do is you can just get the height right there and then put it in. 171 00:08:54,740 --> 00:08:57,800 But I like the way we're doing it now, I think looks kind of cool. 172 00:08:57,980 --> 00:08:58,340 All right. 173 00:08:58,340 --> 00:08:59,570 So we got our size. 174 00:08:59,570 --> 00:09:00,380 We change that. 175 00:09:00,380 --> 00:09:02,000 We change transparency. 176 00:09:02,420 --> 00:09:04,490 Let's do something a little bit new. 177 00:09:04,520 --> 00:09:10,490 Let's change the material to cobblestone. 178 00:09:11,950 --> 00:09:12,370 All right. 179 00:09:12,370 --> 00:09:17,740 If we look at our patio, we have these materials, we can open these up, but we can change them by 180 00:09:17,740 --> 00:09:20,550 hand or we can change them by script. 181 00:09:20,560 --> 00:09:24,070 If you'll notice, there is cobblestone in here. 182 00:09:25,530 --> 00:09:26,280 Right there. 183 00:09:26,580 --> 00:09:32,440 So these look like strings because they're words, but they're actually in an enumeration object. 184 00:09:32,460 --> 00:09:34,030 I'll show you how to do that. 185 00:09:34,050 --> 00:09:37,260 It's not really intuitive if you're new to programming. 186 00:09:37,260 --> 00:09:40,780 So I'm going to say patio material. 187 00:09:40,800 --> 00:09:42,450 Same property name there. 188 00:09:42,780 --> 00:09:43,470 It gives you a hint. 189 00:09:43,470 --> 00:09:47,280 If you go up here, it says E name dot material. 190 00:09:47,910 --> 00:09:48,450 Oh, man. 191 00:09:48,450 --> 00:09:49,140 What's that? 192 00:09:49,170 --> 00:09:49,920 You know. 193 00:09:50,100 --> 00:09:52,260 E name is short for enumeration. 194 00:09:52,260 --> 00:09:53,340 It's a list. 195 00:09:53,340 --> 00:09:59,880 So Roblox made a big list of stuff that you'll probably need to use in your code, and they use it in 196 00:09:59,880 --> 00:10:02,490 their code in this enumeration. 197 00:10:02,490 --> 00:10:10,170 And then there's a subcategory called material, and then you just have to do dot cobblestone. 198 00:10:10,560 --> 00:10:16,710 Now you'll notice some of these base part are a part is a subcategory of base part. 199 00:10:16,710 --> 00:10:23,640 So we could use anything for base part to reign is not a subcategory of base part, or at least not 200 00:10:23,640 --> 00:10:25,860 close enough where you could use the material. 201 00:10:25,860 --> 00:10:30,930 So you have to check if you use like air or terrain only. 202 00:10:30,930 --> 00:10:31,950 We can't use air. 203 00:10:31,950 --> 00:10:32,550 Right. 204 00:10:32,790 --> 00:10:34,020 Foil we could use. 205 00:10:34,020 --> 00:10:35,010 Oh, that's just base part. 206 00:10:35,010 --> 00:10:36,790 You can't use a terrain of foil. 207 00:10:36,810 --> 00:10:38,640 So just so you know that. 208 00:10:38,790 --> 00:10:40,890 Anyway, you can play around with it. 209 00:10:40,890 --> 00:10:42,450 You can learn by trial and error. 210 00:10:42,930 --> 00:10:44,700 I did cobblestone. 211 00:10:45,270 --> 00:10:48,210 I also want to wait though, for the turn. 212 00:10:48,210 --> 00:10:48,970 So I'm going to do this. 213 00:10:48,990 --> 00:10:50,340 Wait one second. 214 00:10:50,340 --> 00:10:51,750 I want to see transitions. 215 00:10:51,750 --> 00:10:55,530 So I put that right after the position so I can see my material change. 216 00:10:55,710 --> 00:10:56,940 Let's go ahead and take a look. 217 00:10:59,350 --> 00:11:01,840 We are almost completed our patio. 218 00:11:03,760 --> 00:11:04,630 Here we go. 219 00:11:04,840 --> 00:11:05,830 There we go. 220 00:11:06,940 --> 00:11:08,980 Cobblestone, maybe. 221 00:11:08,980 --> 00:11:10,870 I don't like that color of gray. 222 00:11:10,900 --> 00:11:11,740 It's kind of gray. 223 00:11:11,770 --> 00:11:13,360 Let's make it like a beige. 224 00:11:13,390 --> 00:11:15,730 That way we can review color. 225 00:11:16,810 --> 00:11:20,170 All right, now I'm going to put my weight statement in here before I forget weight. 226 00:11:22,540 --> 00:11:25,930 I'm going to say that's my little comment. 227 00:11:26,140 --> 00:11:34,060 Change the color of the patio. 228 00:11:34,870 --> 00:11:35,950 Here we go. 229 00:11:36,190 --> 00:11:37,780 I'll say patio. 230 00:11:38,940 --> 00:11:42,180 Patio dot brick color. 231 00:11:42,180 --> 00:11:45,020 So we have color and we have brick color. 232 00:11:45,030 --> 00:11:46,470 I like to use brick color. 233 00:11:46,470 --> 00:11:48,300 So brick color needs a brick color. 234 00:11:48,310 --> 00:11:49,650 So we go ahead and do this. 235 00:11:50,850 --> 00:11:54,300 Let's say equals brick color, brick color new. 236 00:11:54,330 --> 00:11:58,410 And then we can actually spell out what we want from the color wheel. 237 00:11:58,980 --> 00:12:00,270 I'm going to say beige. 238 00:12:00,300 --> 00:12:01,320 I like beige. 239 00:12:01,710 --> 00:12:03,150 There we are. 240 00:12:03,150 --> 00:12:03,820 All done. 241 00:12:03,840 --> 00:12:04,560 Let's check it. 242 00:12:04,560 --> 00:12:05,700 Let's see if it works. 243 00:12:06,270 --> 00:12:07,230 Play. 244 00:12:17,520 --> 00:12:19,230 --, that's pretty cool. 245 00:12:19,260 --> 00:12:21,570 Now we can do stuff with code. 246 00:12:21,570 --> 00:12:24,510 We can actually make some pretty significant modifications. 247 00:12:24,660 --> 00:12:27,850 We still can't create a part of the code yet, but we will. 248 00:12:27,870 --> 00:12:31,170 And then we also want to be able to clone things, right? 249 00:12:31,170 --> 00:12:36,870 Make things exactly the way we want it and then maybe make a whole bunch of them like zombies or something 250 00:12:36,870 --> 00:12:37,410 like that. 251 00:12:37,410 --> 00:12:38,460 That'd be cool. 252 00:12:38,640 --> 00:12:40,980 I will see you in the next video.